<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>人工开柜</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="__HOME_CSS__/font.css">
    <link rel="stylesheet" href="__HOME_CSS__/xadmin.css">
    <script src="__HOME_JS__/echarts.min.js"></script>
    <script src="__HOME_LIB__/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__HOME_JS__/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="__HOME_JS__/html5.min.js"></script>
    <script src="__HOME_JS__/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="L_serial" class="layui-form-label">
                    <span class="x-red">*</span>操作类型</label>
                <div class="layui-input-inline">
                    <select name="type">
                        <option value="">操作类型</option>
                        <option value="1">安检开柜</option>
                        <option value="2">人工开柜</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_model" class="layui-form-label">
                    <span class="x-red">*</span>柜体编号</label>
                <div class="layui-input-inline">
                    <select name="gear">
                        <option value="">柜体编号</option>
                        {volist name="gear" id="vo"}
                        <option value="{$vo.id}">{$vo.gear_serial}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_model" class="layui-form-label">
                    <span class="x-red">*</span>柜门编号</label>
                <div class="layui-input-inline">
                    <select name="door">
                        <option value="">柜门编号</option>
                        {volist name="door" id="vo"}
                        <option value="{$vo.door_serial}">{$vo.door_serial}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_grade" class="layui-form-label">
                    <span class="x-red"></span>班组</label>
                <div class="layui-input-inline">
                    <select id="grade" name="grade" lay-filter="grade">
                        <option value="">班组</option>
                        {volist name="grade" id="vo"}
                        <option value="{$vo.id}">{$vo.grade_name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_uid" class="layui-form-label">
                    <span class="x-red"></span>员工</label>
                <div class="layui-input-inline">
                    <select name="uid" id="uid">
                        <option value="">员工</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">确认开柜</button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer','jquery','laydate'],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //自定义验证规则
        form.verify({
            nikename: function(value) {
                if (value.length < 5) {
                    return '昵称至少得5个字符啊';
                }
            },
            pass: [/(.+){6,12}$/, '密码必须6到12位'],
            repass: function(value) {
                if ($('#L_pass').val() != $('#L_repass').val()) {
                    return '两次密码不一致';
                }
            }
        });
        form.on('select(grade)', function(data){
            $.getJSON("/index/member/get_member?grade="+data.value, function(data){
                var optionstring = "";
                $.each(data.data, function(i,item){
                    optionstring += "<option value=\"" + item.id + "\" >" + item.username + "</option>";
                });
                $("#uid").html('<option value=""></option>' + optionstring);
                form.render('select'); //这个很重要
            });
        });
        //监听提交
        form.on('submit(add)',
            function(data) {
                var door = data.field.door
                var gear = data.field.gear
                var type = data.field.type;
                var grade = data.field.grade;
                var uid = data.field.uid;
                $.ajax({
                    type: 'post',
                    url: '/index/member/admin_open',
                    data: {door: door,gear: gear, type: type, grade:grade,uid:uid },
                    success: function (res) {

                        if (res.code == 0) {

                            layer.msg("开门成功", {
                                    icon: 6
                                },
                                // function() {
                                //     //关闭当前frame
                                //     xadmin.close();
                                //
                                //     // 可以对父窗口进行刷新
                                //     xadmin.father_reload();
                                // }
                            );

                        }else {
                            layer.msg(res.msg,{icon:2})
                        }
                    }
                });
                return false;
            });

        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#L_scrap_time' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#L_check_time' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#L_warning_time' //指定元素
        });
    });</script>

</body>

</html>